package com.ivt.dao;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import com.ivt.model.Attendance;
import com.ivt.model.Courses;
import com.ivt.model.Student;
import com.ivt.utils.enums.Sign;

public interface AttendanceDao extends JpaRepository<Attendance, Long> {

	@QueryHints({ @QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true") })
	@Query("SELECT  count(c) FROM  Attendance c where c.courses = ?1 and c.student = ?2 and c.sign = ?3")
	public long existsByStudent(Courses courses, Student student, Sign sign);
}
